package com.example.demo.controller;

import com.example.demo.core.Result;
import com.example.demo.entity.City;
import com.example.demo.service.CityService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 地理位置城市信息控制器
 *
 * @author 叮当猫的百宝箱
 * @since 1.0
 */
@Tag(name = "地理位置城市信息", description = "地理位置城市信息")
@RestController
@RequestMapping("/geo")
@RequiredArgsConstructor
public class CityController {

    private final CityService cityService;

    /**
     * 根据省份编码获取辖区的市级行政辖区列表
     *
     * @param provinceCode 省份信息编码
     * @return API全局响应对象
     */
    @Operation(summary = "查询城市信息列表")
    @GetMapping("/province/{provinceCode}/city")
    public Result<List<City>> getCityListByProvinceCode(@PathVariable("provinceCode") String provinceCode) {
        List<City> cityList = cityService.getByProvinceCode(provinceCode);
        return Result.ok(cityList);
    }

}
